#!/usr/bin/env python
# -*- coding: utf8 -*-

'''
Created on 2011-8-1

@author: zhongfeng
'''

from j360pageparser import J360buyAllSortParser,J360buySort3PageParser,J360buySort4PageParser
from pageparser import ObuyUrlSummary
from spider import ObuySpider

if __name__ == '__main__':

    parserDict = {0:J360buyAllSortParser,3:J360buySort3PageParser,4:J360buySort4PageParser}
    
    sort3 = ObuyUrlSummary(url = r'http://www.360buy.com/products/737-964-795.html',name='360buy',  
                                 isRecursed = True,catagoryLevel = 3)
    
    digitRoot = ObuyUrlSummary(url = r'http://www.360buy.com/products/652-653-659-0-0-0-0-0-0-0-1-1-2.html', 
                               name='digital',isRecursed = False,catagoryLevel = 4)
    
    j360buyRoot = ObuyUrlSummary(url = r'http://www.360buy.com/allSort.aspx',name='360buy',  
                                 isRecursed = True,catagoryLevel = 0)

    pcare  = ObuyUrlSummary(url = r'http://www.360buy.com/products/652-653-000.html', 
                               name='手机',isRecursed = False,catagoryLevel = 2)
    
    pdigital  = ObuyUrlSummary(url = r'http://www.360buy.com/digital.html',name='digital',catagoryLevel = 1)
    
    pelectronic  = ObuyUrlSummary(url = r'http://www.360buy.com/electronic.html',name='electronic',catagoryLevel = 1)
    
    pcomputer  = ObuyUrlSummary(url = r'http://www.360buy.com/computer.html',name='computer',catagoryLevel = 1)
    
    includes = [pelectronic,pdigital,pcomputer]
    
    spider = ObuySpider(rootUrlSummary = j360buyRoot,parserDict = parserDict,include = includes,exclude = None,threadNum = 5)
    
    spider.spide()
    